#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
#include<stdio.h>

int main()
{
	int l;
	int m;
	int x[10003] = { 0 };
	scanf("%d %d", &l, &m);
	for (int n = 0; n <= l; n++)
	{
		x[n] = 1;
	}
	int a;
	int b;
	for (int i = 0; i < m; i++)
	{
		scanf("%d %d", &a, &b);
		for (int j = a; j <= b; j++)
		{
			x[j] = 0;
		}
	}
	int sum = 0;
	for (int k = 0; k <= l; k++)
	{
		sum = sum + x[k];
	}
	printf("%d", sum);
	return 0;
}